package com.chen.mapper;

import com.chen.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.entity.vo.UserPasswordDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Y·C
 * @since 2023-04-19
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {


    @Update("update sys_user set password = #{newPassword} where username = #{username} and password = #{password}")
    int updatePassword(UserPasswordDTO userPasswordDTO);

    @Update("update sys_user set password = #{newPassword} where username = #{username} and email = #{email} and password = #{password}")
    int updatePasswordFront(UserPasswordDTO userPasswordDTO);

    @Select("SELECT * FROM `sys_user` s RIGHT JOIN user_active  u on s.id = u.user_id WHERE u.active_id = #{id}")
    List<User> selectListInfo(Integer id);
}
